<template>
	<view class="content flex-column bg-sub">
		<view class="scroll-y full-width flex-grow">
			<scroll-view class="full-height" scroll-y="true" lower-threshold="50" @scrolltolower="getMore">
				<van-cell-group v-for="item in list" :key="item.id" custom-class="mx-xl my-xl radius-lg shadow-lg">
					<van-cell @tap="toDetail(item)" :key="item.id" :title="item.label" :label="item.activityMemo">
						<template #right-icon>
							<view class="flex align-end justify-end" hover-class="none" hover-stop-propagation="false">
								<view class="flex align-center justify-center text-sm text-grey">
									<text class="tex-md" selectable="false" space="false" decode="false">
										去参加
									</text>
									<text class="cus-icon cus-icon-right text-sm"></text>
								</view>
							</view>
						</template>
					</van-cell>
				</van-cell-group>
			</scroll-view>
		</view>
	</view>
</template>

<script>
import { findAllActivity } from "@/api/modules/registration";

export default {
	components: {

	},
	data() {
		return {
			pageIndex: 1,
			pageSize: 10,
			hasMore: true,
			list: []
		}
	},
	onPullDownRefresh() {

	},
	onLoad() {
		this.init()
	},
	methods: {
		init() {
			this.pageIndex = 1
			this.hasMore = true
			this.list = []
			this.getList()
		},
		getMore() {
			if (this.hasMore) {
				this.pageIndex++
				this.getList()
			}
		},
		getList() {
			findAllActivity({
				datePeriod: [],
				current: this.pageIndex,
				pageSize: this.pageSize
			}).then(res => {
				console.log(res)
				if (res.code == 200) {
					this.list = [...this.list, ...res.data.records]
				}
				if (this.list.length >= res.data.total) {
					this.hasMore = false
				}
			})
		},
		toDetail(e) {
			uni.navigateTo({
				url: '/pages/home/modules/active/detail?id=' + e.id,
			})
		}
	}
}
</script>

<style lang="scss" scoped></style>